clear;clc;
H_old = [-58.8228781068589 + 198.892794640064i,-1.21833110147180 + 2.40402487088321i,0.0243868782191938 - 0.0111384468559801i,-2.14935564487486 - 0.719225409695810i;
    -0.245272044320914 - 0.660935714985225i,-9.38377971976335 - 53.4355097996488i,0.0425170545042271 - 0.0779284384818814i,0.926405105143966 - 0.306989287332009i;
    -0.0141033193981806 + 0.0157636408248593i,0.211613810724130 - 0.164038954460624i,163.618477353170 + 2.26885011246024i,1.50830907749530 + 1.44863962969990i;
    1.03197981197851 + 1.00090787309430i,1.37347315295496 + 1.92724539124343i,-0.0909444831489928 + 1.67891254896088i,-94.8748793444937 + 91.1404341726689i];

H = H_old;
M = 4;
w = [1.0/6, 1.0/6, 1.0/3, 1.0/3];
p_max = [0.7, 0.8, 0.9, 1.0];
ri = 0;
sigma = 0.001;
p_initial = eye(M);
t_old = 0;
r = 0;
for i  = 1:M
    h = 0;
    for j = 1:M
        if j ~= i
            h = h + H(j,:) * H(j,:)';
        end
    end
    r = r +w(i)* log2(1+ H(i,:)*H(i,:)'/(sigma+h));
end